<%@include file="/pages/common/taglib.jsp"  %>
<%@ page language="java" import="java.util.List" pageEncoding="UTF-8"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.gfa4j.web.UserDetail"%>
<%@page import="com.gfa4j.web.SessionManager"%>
<%@page import="com.wef.system.entity.*"%>
<%@page import="com.gfa4j.wef.utils.CollectionHelper"%>
<%@page import="java.util.Iterator"%>
<script language="javascript">
/**
 * 解决IE不支持document.getElementsByClassName方法来获取element
 * added by shixy
 */
document.getElementsByClassName = function(eleClassName){
	var getEleClass = [];//定义一个数组
	var myclass = new RegExp("\\b"+eleClassName+"\\b");//创建一个正则表达式对像
	var elem = this.getElementsByTagName("*");//获取文档里所有的元素
	for(var h=0;h<elem.length;h++){
	  var classes = elem[h].className;//获取class对像
	  if (myclass.test(classes)) getEleClass.push(elem[h]);//正则比较，取到想要的CLASS对像
	}
	return getEleClass;//返回数组
}

function show(arg){

	var elements = document.getElementsByClassName("SmallMenu");
	for(var i=0;i<elements.length;i++){
		if(elements[i].id == arg){
			elements[i].style.display = "block";
		}else{
			elements[i].style.display = "none";
		}
	}
}

function doChangeModuleAction(moduleCode){
	var toggleDivtoLeft = $("#toggleDivtoLeft");
	var toggleDivtoRight = $("#toggleDivtoRight");
	var ModelLeft = $("#ModuleLeft");
	var ModelRight = $("#ModuleRight");
	var ModuleToggle = $("#ModuleToggle");
	var flag = ModelLeft.is(":hidden");
	if(flag){
		ModelLeft.show();
		ModelRight.css("position","absolute").css("left",ModuleToggle.offset().left+13+"px");
		toggleDivtoRight.hide();
		toggleDivtoLeft.show();
	}
	LoginService.changeModule(moduleCode, function(){
		TableUtils._ajaxDiv({
			ajaxDivId:"menu",
			ajaxUrl:"${ctx}/pages/common/submodel_sub.jsp",
			ajaxParamData:"",
			afterAjax_js_fn:function(){
			}
		});
	});
	if(flag){
		contour('right');
	}
	
}

function doChangeModuleAction2(moduleCode){
	LoginService.changeModule(moduleCode, function(){
	});
}

function doLogoutAction(){
	LoginService.logOut(function(){
		window.parent.location.href="${ctx}/login.jsp";
	});
}
function changeLanguage(obj) {
	var vLang = obj.value;
	if(vLang == 'en'){
		setLangEn();
	}else if(vLang == 'zh_CN'){
		setLangCnS();
	}
}
function setLangEn() {
	LoginService.setLangEn(function() {
		window.parent.location.reload(force = true);
	});
}
function setLangCnS() {
	LoginService.setLangCnS(function() {
		window.parent.location.reload(force = true);
	});
}
function openContactUs(){
	TabTagUtils.newTab('viewContactUs','<bean:message key="system.contactUs" bundle="i18n.common"/>','${ctx}/pages/common/contactUs.jsp');
}
function changeThemes(optVal){
	LoginService.changeThemes(optVal,function(){
		window.parent.location.reload(force = true);
	});
}
$(window).ready(function(){
	var themes = "<%=SessionManager.getAttribute("themes")%>";
	$("#themes").find("option[value='"+themes+"']").attr('selected',true);
	
	var lang = "<%=SessionManager.getAttribute("lang")%>";
	$("#userLanguage").find("option[value='"+lang+"']").attr('selected',true);
})
</script>

<%
	UserDetail userInfo = SessionManager.getUserDetail();
	String contextPath = request.getContextPath();
	if (userInfo != null) {
		List menuItems = userInfo.getMenuItems();
		Map menus = new HashMap();
		for (Iterator iterator = menuItems.iterator(); iterator.hasNext();) {
			MenuItem menuItem = (MenuItem) iterator.next();
			Module module = menuItem.getMenuGroup().getModule();
			List items = null;
			if (menus.get(module) != null) {
				items = (List)menus.get(module);
			} else {
				items = new ArrayList();
				menus.put(module, items);
			}
			items.add(menuItem);
		}
%>
<!--Top-->
  <div id="Top">
    <div id="Logo"></div>
    <div class="FloatRight">
      <div class="Language">
      	<span style="padding-right:10px;">
			<select id="userLanguage" style="width:100px;border:0px;margin:-3px;" onchange="changeLanguage(this)"> 
			  <option value="0">选择语言</option> 
			  <option value="en" onclick="javascript:setLangEn();">English</option> 
			  <option value="zh_CN" onclick="javascript:setLangCnS();">简体中文</option>
			 </select>
			 <select id="themes" style="width:100px;border:0px;margin:-3px;" onchange="changeThemes(this.value)"> 
			 		<option value="0">选择主题</option> 
<!-- 			  		<option value="black-tie">black-tie</option> -->
					<option value="blitzer">blitzer</option>
<!-- 					<option value="cupertino">cupertino</option> -->
<!-- 					<option value="dark-hive">dark-hive</option> -->
<!-- 					<option value="dot-luv">dot-luv</option> -->
<!-- 					<option value="eggplant">eggplant</option> -->
<!-- 					<option value="excite-bike">excite-bike</option> -->
<!-- 					<option value="flick">flick</option> -->
<!-- 					<option value="hot-sneaks">hot-sneaks</option> -->
					<option value="humanity">humanity</option>
<!-- 					<option value="le-frog">le-frog</option> -->
					<option value="mint-choc">mint-choc</option>
<!-- 					<option value="overcast">overcast</option> -->
<!-- 					<option value="pepper-grinder">pepper-grinder</option> -->
					<option value="redmond">redmond</option>
					<option value="smoothness">smoothness</option>
<!-- 					<option value="south-street">south-street</option> -->
					<option value="start">start</option>
					<option value="sunny">sunny</option>
<!-- 					<option value="swanky-purse">swanky-purse</option> -->
<!-- 					<option value="trontastic">trontastic</option> -->
<!-- 					<option value="ui-darkness">ui-darkness</option> -->
					<option value="ui-lightness">ui-lightness</option>
<!-- 					<option value="vader">vader</option> -->
			</select>
		</span>
	      <!-- <span class="OrangeFont"><strong>・</strong></span>&nbsp;<a href="javascript:void(0);" onclick="javascript:setLangEn();" style="cursor:pointer;">ENGLISH</a>&nbsp;&nbsp;
	      <span class="OrangeFont"><strong>・</strong></span>&nbsp;<a href="javascript:void(0);" onclick="javascript:setLangCnS();" style="cursor:pointer;">简体中文</a>&nbsp;&nbsp;&nbsp; -->
	  </div>
	  <div class="Link">
	  	<bean:message key="system.welcome" bundle="i18n.common"/><font color="blue"><%=userInfo.getUserCode() %></font>
	  	<a href="javascript:void(0);" onclick="doLogoutAction();"><bean:message key="system.logOut" bundle="i18n.common"/></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="javascript:void(0);" onclick="javascript:openContactUs();"><bean:message key="system.contactUs" bundle="i18n.common"/></a>
	  </div>
    </div>
    
  </div>
  <!--Top-->
  
  <%
	}
%>